<template>
    <view>
        <!--标题和返回-->
		<cu-custom :bgColor="NavBarColor" isBack :backRouterName="backRouteName">
			<block slot="backText">返回</block>
			<block slot="content">onl_cgform_head_flow</block>
		</cu-custom>
		 <!--表单区域-->
		<view>
			<form>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">表名：</text></view>
                  <input  placeholder="请输入表名" v-model="model.tableName"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">表类型: 0单表、1主表、2附表：</text></view>
                  <input type="number" placeholder="请输入表类型: 0单表、1主表、2附表" v-model="model.tableType"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">表版本：</text></view>
                  <input type="number" placeholder="请输入表版本" v-model="model.tableVersion"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">表说明：</text></view>
                  <input  placeholder="请输入表说明" v-model="model.tableTxt"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">是否带checkbox：</text></view>
                  <input  placeholder="请输入是否带checkbox" v-model="model.isCheckbox"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">同步数据库状态：</text></view>
                  <input  placeholder="请输入同步数据库状态" v-model="model.isDbSynch"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">是否分页：</text></view>
                  <input  placeholder="请输入是否分页" v-model="model.isPage"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">是否是树：</text></view>
                  <input  placeholder="请输入是否是树" v-model="model.isTree"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">主键生成序列：</text></view>
                  <input  placeholder="请输入主键生成序列" v-model="model.idSequence"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">主键类型：</text></view>
                  <input  placeholder="请输入主键类型" v-model="model.idType"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">查询模式：</text></view>
                  <input  placeholder="请输入查询模式" v-model="model.queryMode"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">映射关系 0一对多  1一对一：</text></view>
                  <input type="number" placeholder="请输入映射关系 0一对多  1一对一" v-model="model.relationType"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">子表：</text></view>
                  <input  placeholder="请输入子表" v-model="model.subTableStr"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">附表排序序号：</text></view>
                  <input type="number" placeholder="请输入附表排序序号" v-model="model.tabOrderNum"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">树形表单父id：</text></view>
                  <input  placeholder="请输入树形表单父id" v-model="model.treeParentIdField"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">树表主键字段：</text></view>
                  <input  placeholder="请输入树表主键字段" v-model="model.treeIdField"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">树开表单列字段：</text></view>
                  <input  placeholder="请输入树开表单列字段" v-model="model.treeFieldname"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">表单分类：</text></view>
                  <input  placeholder="请输入表单分类" v-model="model.formCategory"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">PC表单模板：</text></view>
                  <input  placeholder="请输入PC表单模板" v-model="model.formTemplate"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">表单模板样式(移动端)：</text></view>
                  <input  placeholder="请输入表单模板样式(移动端)" v-model="model.formTemplateMobile"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">是否有横向滚动条：</text></view>
                  <input type="number" placeholder="请输入是否有横向滚动条" v-model="model.scroll"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">复制版本号：</text></view>
                  <input type="number" placeholder="请输入复制版本号" v-model="model.copyVersion"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">复制表类型1为复制表 0为原始表：</text></view>
                  <input type="number" placeholder="请输入复制表类型1为复制表 0为原始表" v-model="model.copyType"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">原始表ID：</text></view>
                  <input  placeholder="请输入原始表ID" v-model="model.physicId"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">扩展JSON：</text></view>
                  <input  placeholder="请输入扩展JSON" v-model="model.extConfigJson"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">主题模板：</text></view>
                  <input  placeholder="请输入主题模板" v-model="model.themeTemplate"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">是否用设计器表单：</text></view>
                  <input  placeholder="请输入是否用设计器表单" v-model="model.isDesForm"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">设计器表单编码：</text></view>
                  <input  placeholder="请输入设计器表单编码" v-model="model.desFormCode"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">关联的应用ID：</text></view>
                  <input  placeholder="请输入关联的应用ID" v-model="model.lowAppId"/>
                </view>
              </view>
				<view class="padding">
					<button class="cu-btn block bg-blue margin-tb-sm lg" @click="onSubmit">
						<text v-if="loading" class="cuIcon-loading2 cuIconfont-spin"></text>提交
					</button>
				</view>
			</form>
		</view>
    </view>
</template>

<script>
    import myDate from '@/components/my-componets/my-date.vue'

    export default {
        name: "OnlCgformHeadFlowForm",
        components:{ myDate },
        props:{
          formData:{
              type:Object,
              default:()=>{},
              required:false
          }
        },
        data(){
            return {
				CustomBar: this.CustomBar,
				NavBarColor: this.NavBarColor,
				loading:false,
                model: {},
                backRouteName:'index',
                url: {
                  queryById: "/wuyou/onlCgformHeadFlow/queryById",
                  add: "/wuyou/onlCgformHeadFlow/add",
                  edit: "/wuyou/onlCgformHeadFlow/edit",
                },
            }
        },
        created(){
             this.initFormData();
        },
        methods:{
           initFormData(){
               if(this.formData){
                    let dataId = this.formData.dataId;
                    this.$http.get(this.url.queryById,{params:{id:dataId}}).then((res)=>{
                        if(res.data.success){
                            console.log("表单数据",res);
                            this.model = res.data.result;
                        }
                    })
                }
            },
            onSubmit() {
                let myForm = {...this.model};
                this.loading = true;
                let url = myForm.id?this.url.edit:this.url.add;
				this.$http.post(url,myForm).then(res=>{
				   console.log("res",res)
				   this.loading = false
				   this.$Router.push({name:this.backRouteName})
				}).catch(()=>{
					this.loading = false
				});
            }
        }
    }
</script>
